﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

using CE.User;
using CE.Global;
using CE.Provider;

public partial class Provider_CarInsurance_ViewProviderCarInsuarnceSelectSummary : System.Web.UI.Page
{
    string PageName = "CXDPF";
    string SubPageName = "CXCIRSS";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserId] == null || Session[CE.Global.General.ProviderCompanyId] == null)
        {
            Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
        }
        CheckMainPageAccess();
        CheckSubPageAccess();

        if (!IsPostBack)
        {
            ddlYear.Items.Clear();
            int _year = CE.Global.General.GetUTCDateTime().Year;
            ddlYear.Items.Add(new ListItem("All", "0000"));
            ddlYear.Items.Add(new ListItem(_year.ToString(), _year.ToString()));
            _year = _year - 1;
            ddlYear.Items.Add(new ListItem(_year.ToString(), _year.ToString()));
            LoadProviderCoverageTypeList();
            ddlCXCoverageType.SelectedIndex = 0;
            grvResultViewSummary.DataBind();
        }
    }

    protected void ibtBack_Click(object sender, ImageClickEventArgs e)
    {
        Response.Redirect("~/Provider/CarInsurance/Statistic/ViewStatistics.aspx");
    }

     private void LoadProviderCoverageTypeList()
    {
        CarCoverTypeList _carcovertypelist = new CarCoverTypeList();
        CarCoverTypeDB _carcovertypedb = new CarCoverTypeDB();

        _carcovertypelist = _carcovertypedb.GetProviderCoverTypeList(Convert.ToInt64(Session[CE.Global.General.ProviderCompanyId].ToString()));

        if (_carcovertypelist != null)
        {
            for (int i = 0; i < _carcovertypelist.Count; i++)
            {
                ddlCXCoverageType.Items.Add(new ListItem(_carcovertypelist[i].ProviderCoverTypeDescription, _carcovertypelist[i].CXCoverTypeId.ToString()));
            }
        }

        ddlCXCoverageType.Items.Insert(0, new ListItem("ALL", "0"));
    }

     protected void ImageButton1_Click(object sender, EventArgs e)
    {
        txtModifiedDate.Text = " ";
        if (ddlYear.SelectedIndex > 0)
        {
            txtModifiedDate.Text = ddlYear.Text;
            if (ddlMonth.SelectedIndex > 0)
            {
                txtModifiedDate.Text += ddlMonth.Text;
                if (ddlDay.SelectedIndex > 0)
                {
                    txtModifiedDate.Text += ddlDay.Text;
                }
                else
                {
                    ddlDay.SelectedIndex = 0;
                }
            }
            else
            {
                ddlMonth.SelectedIndex = 0;
                ddlDay.SelectedIndex = 0;
            }
        }
        else
        {
            ddlMonth.SelectedIndex = 0;
            ddlDay.SelectedIndex = 0;
        }
        grvResultViewSummary.DataBind();
    }

     private void CheckMainPageAccess()
     {
         Int64 PageAccess = General.GetProviderMainPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                         Convert.ToInt64(Session[General.UserId].ToString()), PageName);
         if (PageAccess == 0)
         {
             //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
             Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
         }
     }

     private void CheckSubPageAccess()
     {
         Int64 PageAccess = General.GetProviderSubPageAccess(Convert.ToInt64(Session[General.ProviderCompanyId].ToString()),
                                                         Convert.ToInt64(Session[General.UserId].ToString()), SubPageName);
         if (PageAccess == 0)
         {
             //Response.Redirect("~/Provider/UserMessage.aspx?errorcode=2000");
             Response.Redirect("~/Provider/UserMessage.aspx?mt=UM&ec=2000");
         }
     }

}
